const CONFIG = require('../config/config');


const createCookie = function (ctx,jwtStr) {
    var cookieExpireTime = new Date();
    cookieExpireTime.setDate(cookieExpireTime.getDate() + CONFIG.COOKIETIME);
    ctx.cookies.set(CONFIG.COOKIEJWTNAME, jwtStr, {
        domain: CONFIG.COOKIEDOMAIN, // 写cookie所在的域名
        path: '/',
        //maxAge: 2*60*60*1000,   // cookie有效时长,单位为毫秒,权重比expires高
        expires: cookieExpireTime, // cookie失效时间
        httpOnly: false,  // 是否只用于http请求中获取,默认true
        overwrite: false  // 是否允许重写
    })
    console.log('======ctx.cookies.get(CONFIG.COOKIEJWTNAME)',ctx.cookies.get(CONFIG.COOKIEJWTNAME));
}







module.exports = {
    createCookie
}